// 要操作的元素
const menu_box=document.querySelector('.menu-box');
const menu_button=document.querySelector('.menu-button');
const page_left=document.getElementById('left')
const page_right=document.getElementById('right')
const home=document.getElementById('home')
const baidu=document.getElementById('close')

var pages=['/pages/page1.html','/pages/page2.html','/pages/page3.html','/pages/page4.html','/pages/page5.html','/pages/page6.html',
'/pages/page7.html','/pages/page8.html','/pages/page9.html','/pages/page10.html','/pages/page11.html','/pages/page12.html','/pages/page13.html',
'/pages/page14.html','/pages/page15.html','/pages/page16.html',]
var mores=['https://baike.baidu.com/item/%E4%B8%AD%E5%9B%BD%E5%8F%B2%E5%89%8D%E6%97%B6%E6%9C%9F/3878283?fromModule=search-result_lemma',
'https://baike.baidu.com/item/%E5%A4%8F%E6%9C%9D/22101?fromModule=lemma_search-box',
'https://baike.baidu.com/item/%E5%95%86%E6%9C%9D/194655?fromModule=lemma_search-box',
'https://baike.baidu.com/item/%E8%A5%BF%E5%91%A8/510056',
'https://baike.baidu.com/item/%E6%98%A5%E7%A7%8B/982807?fromtitle=%E6%98%A5%E7%A7%8B%E6%97%B6%E6%9C%9F&fromid=511882&fromModule=lemma_search-box',
'https://baike.baidu.com/item/%E6%98%A5%E7%A7%8B/982807?fromtitle=%E6%98%A5%E7%A7%8B%E6%97%B6%E6%9C%9F&fromid=511882&fromModule=lemma_search-box',
'https://baike.baidu.com/item/%E7%A7%A6%E6%9C%9D?fromModule=lemma_search-box',
'https://baike.baidu.com/item/%E6%B1%89%E6%9C%9D?fromModule=lemma_search-box',
'https://baike.baidu.com/item/%E9%AD%8F%E6%99%8B%E5%8D%97%E5%8C%97%E6%9C%9D/8554577?fromModule=lemma-qiyi_sense-lemma',
'https://baike.baidu.com/item/%E9%9A%8B%E6%9C%9D/196103?fromModule=lemma_search-box',
'https://baike.baidu.com/item/%E5%94%90%E6%9C%9D/53699?fromModule=lemma_search-box',
'https://baike.baidu.com/item/%E4%BA%94%E4%BB%A3%E5%8D%81%E5%9B%BD/433599?fromtitle=%E4%BA%94%E4%BB%A3%E5%8D%81%E5%9B%BD%E6%97%B6%E6%9C%9F&fromid=9374487&fromModule=lemma_search-box',
'https://baike.baidu.com/item/%E5%AE%8B%E6%9C%9D/2919?fromModule=lemma_search-box',
'https://baike.baidu.com/item/%E5%85%83%E6%9C%9D/266205?fromModule=lemma_search-box',
'https://baike.baidu.com/item/%E6%98%8E%E6%9C%9D/141291?fromModule=lemma_search-box',
'https://baike.baidu.com/item/%E6%B8%85%E6%9C%9D/175141?fromModule=lemma_search-box',]
//找到上一页和下一页的路径
var left_page;
var right_page;
var this_page;
var current=window.location.pathname
for(var i=0;i<16;i++)
{
    if(pages[i]==current){
        this_page=i;
        left_page=i-1;
        if(left_page==-1){
            left_page=15
        }
        right_page=i+1;
        if(right_page==16){
            right_page=1
        }
        break;
    }
}
// 为菜单按钮绑定点击事件
menu_button.addEventListener('click',function(){
    menu_box.classList.toggle('active');
})

//  向前翻页
page_left.addEventListener('click',function(){
    window.location.href= pages[left_page];
})
//向后翻页
page_right.addEventListener('click',function(){
    window.location.href= pages[right_page];
})
home.addEventListener('click',function(){
    window.location.href='/index/index.html';
})

// 跳转到百度百科
baidu.addEventListener('click',function(){
    window.location.href=mores[this_page];
})